home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / allfiles / Centri / Centri.dir / 00008_Script_Sprite Blender < prev    next >
Text File  |  1999-02-25  |  2KB  |  70 lines

  1.  
  2. property startBlend 
  3.  
  4. -- how far away should the fade begin?
  5. property StartFadePoint 
  6.  
  7. -- how far away should the fade stop 
  8. -- (at which point the blend should = 100) ?
  9.  
  10. property EndFadePoint
  11.  
  12.  
  13. on beginSprite me -- sets initial blend
  14.   puppetsprite  the spriteNum of me, 1
  15.   set the blend of sprite the spriteNum of me = startBlend
  16.   updatestage
  17. end
  18.  
  19. on exitFrame me -- provides the trigger for the blend updates
  20.   sendSprite  (the spritenum of me, #blendit)
  21. end
  22.  
  23.  
  24. on blendSprite which, what -- does the blending :)
  25.   set the blend of sprite which = what
  26.   updatestage
  27. end  
  28.  
  29. on blendit me 
  30.   set dv = abs((the locV of sprite the spriteNum of me) - the mousev)
  31.   set  dH = abs((the locH of sprite the spriteNum of me) - the mouseh)
  32.   set distance = sqrt( dV * dV + dH * dH ) 
  33.   if distance < EndFadePoint then
  34.     blendSprite the spriteNum of me,100 
  35.     exit
  36.   end if
  37.   if distance < StartFadePoint then
  38.     set percentage = (distance*100/StartFadePoint) 
  39.     set blendToValue =  (100-percentage)
  40.     if blendToValue < startBlend then set blendToValue =  startBlend 
  41.     blendSprite the spriteNum of me,blendToValue 
  42.   else
  43.     blendSprite the spriteNum of me,startBlend 
  44.   end if
  45.   updatestage
  46.   
  47.   if distance < 20 then 
  48.     set the memberNum of sprite the SpriteNum of me = 18
  49.   else 
  50.     set the memberNum of sprite the SpriteNum of me = 3
  51.   end if
  52.   
  53.   
  54. end
  55.  
  56. on getPropertyDescriptionList
  57.   set p_list = [¼
  58.                           #startBlend: [ #default:0, #format:#integer, #comment:"Initial Blend",#range: [#min:0,#Max:100]] ,¼
  59.                              #StartFadePoint: [ #default:100, #format:#integer, #comment:"Trigger Point", #range:[#min:0,#Max:500]],¼
  60.                              #EndFadePoint: [ #default:0, #format:#integer, #comment:"End Trigger Point", #range:[#min:0,#Max:50]] ¼
  61.                           ]
  62.   return p_list
  63. end
  64.  
  65.  
  66. on getBehaviorDescription
  67.   return  "Creates sprites that fade in and out (using the sprite blend property) depending how far they are from the mouse. " &return&return&¼
  68.                           "Try different inks for your sprites - different images require different settings. Also, there appears to be a bug in Director 6 that prevents sprites with a blend of 0 from being totally hidden. "
  69.   
  70. end